<template>
  <div class="form-container">
    <h2>登录成功</h2>
    <p class="text-center">欢迎，{{ userStore.username }}！</p>
    <p class="text-center">你的用户 ID 是：{{ userStore.userId }}</p>
    <button @click="handleLogout" class="mt-4">退出登录</button>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router';
import { useUserStore } from '../stores/userStore';

const router = useRouter();
const userStore = useUserStore();

const handleLogout = () => {
  userStore.logout();
  router.push('/login');
};
</script>

<style scoped>
.text-center {
  text-align: center;
}
.mt-4 {
  margin-top: 1rem;
}
</style>